import React from 'react';
import { Alert, Button, Dimensions, SafeAreaView, StyleSheet, Text, View } from 'react-native';

//点击事件练习 Button
const ButtonPage = () => {

    const buttonClick1 = () => {
        Alert.alert("警告标题1", "警告内容1", [
            {
                text: "取消",
                onPress: () => {
                    console.log('取消')
                },
                style: 'cancel'
            },
            {
                text: "确认",
                onPress: () => {
                    console.log('确认')
                },
                style: "default"
            }
        ])
    }

    const buttonClick2 = () => {
        Alert.alert("警告标题2", "警告内容3", [
            {
                text: "稍后再试",
                onPress: () => {
                    console.log('确认')
                },
                style: "default"
            },
            {
                text: "取消",
                onPress: () => {
                    console.log('取消')
                },
                style: 'cancel'
            },
            {
                text: "确认",
                onPress: () => {
                    console.log('确认')
                },
                style: "default"
            }
        ])
    }


    return (
        <View style={styles.root}>
            <Button
                title='点击事件1'
                onPress={() => {
                    Alert.alert("点击了第一个")
                }}
            />
            <Button
                title='点击事件2'
                onPress={() => {
                    buttonClick2()
                }}
                color="#ff0000"
            />
            <Button
                title='点击事件3'
                onPress={() => {
                    buttonClick1()
                }}
                color="#333"
            />
        </View>
    );
};

const styles = StyleSheet.create({
    root: {
        justifyContent: "space-around",
        alignItems: "center",
        height: Dimensions.get("window").height
    }
})

export default ButtonPage;
